package cn.bytecollege.service;

import cn.bytecollege.dao.BaseDao;
import cn.bytecollege.dao.RoomCategoryDao;
import cn.bytecollege.entity.RoomCategory;

import java.util.List;

public class RoomCategoryService{
    private RoomCategoryDao roomCategoryDao=null;
    public RoomCategoryService(){
        roomCategoryDao=new RoomCategoryDao();
    }
    /**
     * 查询所有分类
     * YL
     */
    public List<RoomCategory> find(){
        return roomCategoryDao.find();
    }
    /**
     * @author LH
     * 通过分类id查询分类
     * @param roomCategoryId
     * @return
     */
    public RoomCategory findByRoomCategoryId(Integer roomCategoryId){
        return roomCategoryDao.findByRoomCategoryId(roomCategoryId);
    }
    /**
     * 添加新的房间分类
     * @param roomCategory
     * @return
     * @author Mr.H
     */
    public int save(RoomCategory roomCategory) {
        return roomCategoryDao.save(roomCategory);
    }

    /**
     * 根据房间分类名查找房间分类
     * @param categoryName
     * @return
     * @author Mr.H
     */
    public RoomCategory findRoomCategoryByCategoryName(String categoryName){
        List<RoomCategory> list= roomCategoryDao.findRoomCategoryByCategoryName(categoryName);
        RoomCategory roomCategory=null;
        if (list.size()>0){
            roomCategory=list.get(0);
        }
        return roomCategory;
    }

    /**
     * 根据ID查询分类信息
     * @param roomCategoryId
     * @return
     * @author Mr.H
     */
    public RoomCategory findRoomCategoryByCategoryId(Integer roomCategoryId){
        List<RoomCategory> list= roomCategoryDao.findRoomCategoryByCategoryId(roomCategoryId);
        RoomCategory roomCategory=null;
        if (list.size()>0){
            roomCategory=list.get(0);
        }
        return roomCategory;
    }

    /**
     * 更新房间分类信息
     * @param roomCategory
     * @return
     * @author Mr.H
     */
    public int update(RoomCategory roomCategory){
        return roomCategoryDao.update(roomCategory);
    }

    /**
     * 查询所有的未删除的分类
     * @return
     * @author Mr.H
     */
    public List<RoomCategory> findAll(){
        return roomCategoryDao.findAll();
    }

    /**
     * 根据id删除分类，逻辑删除
     * @param categoryId
     * @return
     * @author Mr.H
     */
    public int deleteCategory(Integer categoryId){
        return roomCategoryDao.deleteCategory(categoryId);
    }

}
